<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2019/1/16
 * Time: 15:29
 */

namespace app\modules\templateMethod;


abstract class Journey
{
    private $_thingsToDo = [];

    final public function takeATrip()
    {
        $this->_thingsToDo[] = $this->buyAFlight();
        $this->_thingsToDo[] = $this->takePlane();
        $this->_thingsToDo[] = $this->enjoyVacation();
        $buyGift = $this->buyGift();

        if ($buyGift !== null) {
            $this->_thingsToDo[] = $buyGift;
        }
    }

    abstract protected function enjoyVacation(): string;

    private function buyAFlight(): string
    {
        return 'buy a flight ticket';
    }

    private function takePlane(): string
    {
        return 'taking the plane';
    }

    protected function buyGift()
    {
        return null;
    }

    public function getThingsToDo()
    {
        return $this->_thingsToDo;
    }
}